<div class="page" id="app">
  <div class="card mt4">
    <div class="weui-form" style="max-width: 480px; margin: 0 auto">
      <div class="weui-form__text-area">
        <h2 class="weui-form__title"><%=title%></h2>
        <div class="weui-form__desc">管理后台登陆</div>
      </div>

      <div class="my2">
        <div class="weui-cells">
          <div class="weui-cell weui-cell_active">
            <div class="weui-cell__hd">
              <label class="weui-label">密码</label>
            </div>
            <div class="weui-cell__bd">
              <input v-model="password" placeholder="请输入密码" type="password" class="weui-input" />
            </div>
          </div>
        </div>
      </div>
      <div class="weui-form__opr-area">
        <button @click="signin" class="weui-btn weui-btn_primary">登陆</button>
      </div>
      <div class="mt2"></div>
    </div>
  </div>
</div>

<script>
  new Vue({
    el: "#app",
    data: function () {
      return {
        password: "",
      };
    },
    methods: {
      signin: function () {
        axios
          .post("/admin/signin", {
            password: this.password,
          })
          .then(function (res) {
            if (res.data.status) {
              weui.toast("登陆成功, 马上跳转", {
                duration: 300,
                callback: function () {
                  location.href = "/admin/home";
                },
              });
            } else {
              weui.topTips("密码不正确");
            }
          });
      },
    },
  });
</script>
